<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-form @submit.native.prevent label-position="right">
        <el-row class="cu-common-search-box" :gutter="15">
          <el-col :span="6">
            <el-form-item label="校区名称" prop="contact">
              <el-input v-model="query.info" clearable :style="{ width: '100%' }" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校区品牌" prop="brand">
              <el-select v-model="query.brand" placeholder="">
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="6">
              <el-form-item label="校区区域">
                <custom-address v-model="query.area"  :multiple="true" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="校区状态">
                <el-select v-model="query.status" placeholder="" clearable>
                  <el-option v-for="(item, index) in statusOptions" :key="item.id" :label="item.fullName" :value="item.enCode" />
                </el-select>
              </el-form-item>
            </el-col>
          </template>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()" native-type="submit">查询</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
              <el-button type="text" icon="el-icon-arrow-down" @click="showAll = true" v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll = false" v-else>收起</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()" >新增</el-button>
            <el-button type="text" icon="el-icon-download" @click="exportData()" v-has="'btn_download'">导出</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list">
          <el-table-column prop="brand" label="校区品牌" align="center" width="80">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="code" label="校区编码" align="center" width="80" />
          <el-table-column prop="fullName" label="校区全称" align="left" show-overflow-tooltip />
          <el-table-column prop="shortName" label="校区简称" align="left" width="200" show-overflow-tooltip />
          <el-table-column prop="investors" label="新投资人" align="left" show-overflow-tooltip />
          <el-table-column prop="manager" label="校区负责人" align="left" width="100" />
          <el-table-column prop="managerMobile" label="负责人电话" align="center" width="100" />
          <el-table-column prop="status" label="状态" align="center" width="80">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.status == 'preparation'" key="筹备" type="" effect="dark">
                筹备
              </el-tag>
              <el-tag v-if="scope.row.status == 'normal'" key="正常" type="success" effect="dark">
                正常
              </el-tag>
              <el-tag v-if="scope.row.status == 'expires'" key="到期" type="info" effect="dark">
                待续费
              </el-tag>
              <el-tag v-else-if="scope.row.status == 'suspended'" key="暂停" type="warning" effect="dark">
                暂停
              </el-tag>
              <el-tag v-else-if="scope.row.status == 'close'" key="闭校" type="danger" effect="dark">
                闭校
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="160" align="center">
            <template slot-scope="scope">
              <el-button type="text" size="mini" class="cu-table-delBtn" @click="onRecordsFormHandle(scope.row.id)">转让记录</el-button>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
    <records-form v-if="recordsVisible" ref="RecordsForm" @refresh="refresh" />
    <status-box v-if="statusVisible" ref="StatusBox" @refresh="refresh" />
    <ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
<style lang="scss" scoped>
@import url(index.scss);
</style>
